package com.travel.dao.impl;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.travel.base.impl.BaseDaoImpl;
import com.travel.bean.Hotspot;
import com.travel.dao.HotSpotDao;

@Repository("hotSpotDaoImpl")
public class HotSpotDaoImpl extends BaseDaoImpl<Hotspot> implements HotSpotDao {

	@Override
	public List<Hotspot> getHotSpotByPage(Map map, Integer pageNum, Integer pageSize) {
		// TODO Auto-generated method stub
		
		Session session=this.hibernateTemplate.getSessionFactory().openSession();
		Criteria criteria=session.createCriteria(Hotspot.class);
		
		if(map!=null){
			criteria.add(Restrictions.allEq(map));
		}
		
		if(pageNum!=null&&pageSize!=null){
			criteria.setFirstResult((pageNum-1)*pageSize);
			criteria.setMaxResults(pageSize);
		}
		List<Hotspot> Hotspots=criteria.list();
		if(session!=null&&session.isOpen()){
			session.close();
		}
		return Hotspots;
	}

	

}
